package com.teame.readbaby;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.teame.readbaby.util.GloableParams;
import com.teame.readbaby.vo.Userinfo;

public class AccountManageActivity extends BaseActivity {
	private TextView my_name_text; // 登录名
	private TextView my_bonus_text; // bonus积分
	private TextView my_level_text; // 类型
	private TextView loginOut_text; // 底下退出按钮

	private TextView head_back_text;

	private Userinfo userInfo;

	@Override
	protected void onClickEvent(View paramView) {
		if (loginOut_text == paramView) {// 用户点击退出
			GloableParams.userInfo = null;
			Intent intent = new Intent(this, LoginActivity.class);
			startActivity(intent);
			finish();
		} else if (head_back_text == paramView) {// 用户点击退出
			Intent intent = new Intent(this, MoreActivity.class);
			startActivity(intent);
			finish();
		}
	}

	@Override
	protected void findViewById() {
		my_name_text = (TextView) findViewById(R.id.my_name_text);
		my_bonus_text = (TextView) findViewById(R.id.my_bonus_text);
		my_level_text = (TextView) findViewById(R.id.my_level_text);
		loginOut_text = (TextView) findViewById(R.id.loginOut_text);
		head_back_text = (TextView) findViewById(R.id.head_back_text);
	}

	@Override
	protected void loadViewLayout() {
		setContentView(R.layout.my_account_activity);
	}

	@Override
	protected void processLogic() {
		userInfo = GloableParams.userInfo;
		if (userInfo == null) {
			Intent intent = new Intent(this, LoginActivity.class);
			startActivity(intent);
			finish();
		} else {
			my_name_text.setText(userInfo.getUserName());
			my_bonus_text.setText(userInfo.getBonus() + "");
			my_level_text.setText(userInfo.getLevel());
		}
	}

	@Override
	protected void setListener() {
		loginOut_text.setOnClickListener(this);
		head_back_text.setOnClickListener(this);
	}

}
